<?php

namespace App\Http\Requests\System;

use Illuminate\Foundation\Http\FormRequest;

class SysRoleRequest extends FormRequest
{
    /**
     * 表示验证器是否应在第一个规则失败时停止
     *
     * @var bool
     */
    protected $stopOnFirstFailure = true;

    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
     */
    public function rules(): array
    {
        return [
            'name' => ['required', 'max:50'],
            'name_en' => ['required', 'max:50'],
        ];
    }

    /**
     * 获取验证错误的自定义属性
     *
     * @return string[]
     */
    public function attributes()
    {
        return [
            'name' => '角色名称',
            'name_en' => '英文角色名称',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息
     *
     * @return string[]
     */
    public function messages()
    {
        return [
            'name.required' => '角色名称不能为空',
            'name_en.required' => '英文角色名称不能为空',
        ];
    }
}
